package com.ruoyi.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.ProjectModelInfo;
import com.ruoyi.project.service.IProjectModelInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目建模Controller
 * 
 * @author ruoyi
 * @date 2022-08-26
 */
@RestController
@RequestMapping("/ProjectModelInfo1/ProjectModelInfo")
public class ProjectModelInfoController extends BaseController
{
    @Autowired
    private IProjectModelInfoService projectModelInfoService;

    /**
     * 查询项目建模列表
     */
    @PreAuthorize("@ss.hasPermi('ProjectModelInfo1:ProjectModelInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectModelInfo projectModelInfo)
    {
        startPage();
        List<ProjectModelInfo> list = projectModelInfoService.selectProjectModelInfoList(projectModelInfo);
        return getDataTable(list);
    }

    /**
     * 导出项目建模列表
     */
    @PreAuthorize("@ss.hasPermi('ProjectModelInfo1:ProjectModelInfo:export')")
    @Log(title = "项目建模", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectModelInfo projectModelInfo)
    {
        List<ProjectModelInfo> list = projectModelInfoService.selectProjectModelInfoList(projectModelInfo);
        ExcelUtil<ProjectModelInfo> util = new ExcelUtil<ProjectModelInfo>(ProjectModelInfo.class);
        util.exportExcel(response, list, "项目建模数据");
    }

    /**
     * 获取项目建模详细信息
     */
    @PreAuthorize("@ss.hasPermi('ProjectModelInfo1:ProjectModelInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(projectModelInfoService.selectProjectModelInfoById(id));
    }

    /**
     * 新增项目建模
     */
    @PreAuthorize("@ss.hasPermi('ProjectModelInfo1:ProjectModelInfo:add')")
    @Log(title = "项目建模", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectModelInfo projectModelInfo)
    {
        return toAjax(projectModelInfoService.insertProjectModelInfo(projectModelInfo));
    }

    /**
     * 修改项目建模
     */
    @PreAuthorize("@ss.hasPermi('ProjectModelInfo1:ProjectModelInfo:edit')")
    @Log(title = "项目建模", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectModelInfo projectModelInfo)
    {
        return toAjax(projectModelInfoService.updateProjectModelInfo(projectModelInfo));
    }

    /**
     * 删除项目建模
     */
    @PreAuthorize("@ss.hasPermi('ProjectModelInfo1:ProjectModelInfo:remove')")
    @Log(title = "项目建模", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectModelInfoService.deleteProjectModelInfoByIds(ids));
    }
}
